import { PureStandardProps } from "@/src/consts"
import Global from "@/src/lib/global"
import { Image, ITouchEvent, View } from "@tarojs/components"
import "./home-section.scss"

export interface HomeSectionProps extends PureStandardProps {
    children?: any,
    backgroundImage?: string
    onClick?: (e: ITouchEvent<any>) => void
}

const HomeSection = (props: HomeSectionProps) => {
    return (
        <View {...props} className={[props.className, "home-section"].join(" ")} onClick={ props.onClick }>
            <View className="home-section-warp">
                <Image className="home-section-bg" src={ props.backgroundImage?.startsWith("http") ? props.backgroundImage : Global.loadImage(props.backgroundImage) }/>
                <View className="home-section-content">                
                    { props.children }
                </View>
            </View>
        </View>
    )
}

export default HomeSection